package com.ruoyi.project.er.enums;

import java.util.HashMap;
import java.util.Map;

public enum PaeaErrorSource {
	S凭证扫描(200, "凭证扫描","#ff4d02"),
	S凭证补扫(210, "凭证补扫","#ff4d02"),

	S人工补录(300, "人工补录","#ff4d02"),
	S强制补录(310,"强制补录",""),

	S重点监控(400, "重点监控","red"),
	S风险预警(410, "风险预警",""),
	S质量检查(420, "质检","blue"),
	S再监控(421, "再监控","");

	// 差错种类 0-有流水差错 1-无流水差错 2-风险预警差错,
	// 差错来源（0差错处理、1人工补录、2重点监控、3风险预警、4人工选择监控、5再监控）
	public static PaeaErrorSource toPaeaErrorSource(Integer value) {
		return codeMap.get(value);
	}

	public static String getNameByCode(Integer value) {
		PaeaErrorSource status = codeMap.get(value);
		if (status != null) {
			return status.getName();
		}
		return "未知状态";
	}


	private static Map<Integer, PaeaErrorSource> codeMap;
	private static Map<String, PaeaErrorSource> nameMap;
	static {
		codeMap = new HashMap<Integer, PaeaErrorSource>();
		nameMap = new HashMap<String, PaeaErrorSource>();
		for (PaeaErrorSource status : PaeaErrorSource.values()) {
			codeMap.put(status.getValue(), status);
			nameMap.put(status.getName(), status);
		}
	}
	private Integer value;
	private String name;
    private String color;
	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	private PaeaErrorSource(int value, String name,String color) {
		this.value = value;
		this.name = name;
		this.color = color;
	}

	public int getValue() {
		return value;
	}

	public String getName() {
		return name;
	}

	public String toString() {
		return this.getValue() + "-" + this.getName();
	}

	public static void main(String[] args) {
		for (PaeaErrorSource status : PaeaErrorSource.values()) {
			System.out.println(status);
		}
	}

	public static String getColorNameByCode(Integer value) {
		PaeaErrorSource status = codeMap.get(value);
		if (status != null) {
			return "<font color=" + status.getColor() +  ">"+status.getName() + "</font>";
		}
		return "未知状态";
	}

}
